home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
PREFILTR.80
< prev
next >
Wrap
Text File
|
1996-05-04
|
4KB
|
114 lines
/*A pre filter for SRE-FILTER.
This pre-filter implements support for the GOREMOTE server
remote control package of GoServe.
If PRE_FILTER=YES, then only SUPERUSERs will be allowed acces to
GoRemore. If PRE_FILTER=FIRST, then everyone is given access.
In this version, PREFILTR will check to see if the request is for
GORMxxx or GOREMOTE.HTM, or GOREMOTE/GORMxxx and GOREMOTE/GOREMOTE.HTM.
Thus, GOREMOTE must be installed either in the root of the data directory,
or in the GOREMOTE/ subdirectory of the data directory.
PREFILTR should return: status , message:
status=0: SRE-FILTER should continue
status=1: some form of completion, SRE-FILTER should end (perhaps after
recording request info)
The message will be saved as the PREFILTER_RESULT variable
*/
prefiltr:
parse arg source,request,sel,privs
issent=completed()
if issent=1 then /* if cached request, nothing here to do.. */
return '1 , ok cached'
tsel=translate(sel)
if abbrev(tsel,'GOR')=0 & abbrev(tsel,'GOS')=0 then return '0 , ok' /* quick check */
/* see it this is GOREMOTE.HTM or GORM*.HTM, in either main or
GOREMOTE directory */
foo=translate(sel,' ','/\')
endword=word(foo,words(foo))
sel1=strip(tsel,,'/')
hi1=abbrev(sel1,"GOREMOTE")
hi2=abbrev(sel1,"GORM")
hi3=abbrev(sel1,"GOREMOTE/GORM")
hi4=abbrev(sel1,"GOREMOTE/GOREMOTE")
if hi1+hi2+hi3+hi4=0 then
return '0 , ok'
/* if here, it's a goremote command -- srefilter will not have to
do anything with this request (except record it). */
verb=word(request,1)
/* check privs? */
if privs<>" " then do
tp=translate(privs)
IF verb="GET" then do
if (wordpos("SUPERUSER",tp)+wordpos("INHOUSE",tp))=0 then do
foo=response('unauth', 'you do not have sufficient privileges for '||endword)
return '1, not allowed ' /* let srefilter record this .. */
END
end
if verb="POST" then do
if wordpos("SUPERUSER",tp)=0 then DO
foo=response('unauth', 'you do not have sufficient privileges for '||endword)
return '1, not allowed ' /* let srefilter record this .. */
END
end
end
sel=sref_replacestrg(sel,'GOREMOTE.HTM','GOREMOTE') /* a common error .. */
/* if here, goremote and sufficient privs -- do it ! */
if verb="GET" then do
say " GoRemote= " verb sel
foo=goremote(verb,sel)
end
else do
say " GOREMOTE= " verb endword
foo=goremote(verb,endword)
end
return ' 1 , did goremote '
response: procedure
parse arg request, message
select
when request='badreq' then use='400 Bad Request Syntax'
when request='notfound' then use='404 Not found'
when request='forbid' then use='403 Forbidden'
when request='unauth' then use='401 Unauthorized'
otherwise
end /* Add others to this list as needed */
/* Now set the response and build the response file */
'RESPONSE HTTP/1.0' use /* Set HTTP response line */
parse var use code text
crlf='0d0a'x; out=''
out=out||'<!doctype html public "-//IETF//DTD HTML 2.0//EN">'crlf
out=out||"<html><head><title>"text"</title></head>"crlf
out=out||"<body><h2>Sorry...</h2>"crlf
out=out||"<p>The request from your Web client" message"."crlf
out=out||"<hr><em>HTTP response code:</em>" code '['text']'crlf
out=out||"<br><em>From server at:</em>" servername()crlf
out=out||"<br><em>Running:</em>" server()crlf
out=out||"</body></html>"crlf
'VAR TYPE text/html AS Response NAME out' /* send it */
return '' /* [called as function] */